<template>
  <div class="xtx-goods">
    <router-link to="/" class="xtx-goods__image">
      <img v-lazyload="goods.picture" alt="" />
    </router-link>
    <p class="xtx-goods__desc">{{ goods.desc }}</p>
    <p class="xtx-goods__type">{{ goods.name }}</p>
    <p class="xtx-goods__price">&yen;{{ goods.price }}</p>
    <div class="xtx-goods-extra">
      <router-link to="/">
        <span class="xtx-goods-extra__resemblance">找相似</span>
        <span class="xtx-goods-extra__more">发现更多宝贝&gt;</span>
      </router-link>
    </div>
  </div>
</template>

<script setup lang="ts">
import { Goods } from '@/api/home/types.d'
defineOptions({
  name: 'Goods'
})

/** Props */
interface Props {
  goods: Goods
}

defineProps<Props>()
</script>

<style lang="scss" scoped>
.xtx-goods {
  position: relative;
  overflow: hidden;
  padding: 10px 30px;
  width: 240px;
  height: 300px;
  background-color: $basic-white;
  border: solid 1px transparent;
  transition: border 0.3s;

  &:hover {
    cursor: pointer;
    border-color: $xtx-color;

    .xtx-goods-extra {
      transform: translateY(0);
    }
  }

  &__image {
    display: block;
    margin: 0 auto;
    width: 160px;
    height: 160px;

    img {
      width: 100%;
      height: 100%;
    }
  }

  p {
    margin-top: 6px;
  }

  &__desc {
    display: -webkit-box;
    overflow: hidden;
    height: 44px;
    line-height: 21px;
    text-overflow: ellipsis;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  &__type {
    overflow: hidden;
    height: 24px;
    color: #666;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  &__price {
    margin-top: 10px;
    color: $price-color;
    font-size: 20px;
  }

  &-extra {
    position: absolute;
    bottom: 0;
    left: 0;
    padding: 5px 0;
    width: 100%;
    background-color: $xtx-color;
    transform: translateY(100%);
    transition: transform 0.3s;

    span {
      display: block;
      margin: 0 auto;
      width: 120px;
      color: $basic-white;
      text-align: center;
    }

    &__resemblance {
      line-height: 36px;
      font-size: 20px;
      border-bottom: solid 1px $basic-white;
    }

    &__more {
      line-height: 34px;
      font-size: 14px;
    }
  }
}
</style>
